import {WidgetClass} from "../atom/widget";
export class Camera extends WidgetClass {
  constructor(options = {}) {
    super(options);
    const {ports, UI} = options;
    if (UI) {
      this.UI.data = UI.data;
    } else {
      this.UI.data = {
        usePtzSpeed:false,
        usePowerOn:true,
        usePowerOff:true,
        useFocus:false,
        presetSize: {
          width: 120,
          height: 46,
        },
        presets: [],
        backgroundColor: "bg-color-page", //bg-color-page
        componentColor: "bg-color-secondarypage",
        textColor: "text-color-secondary",
        contentColor: "bg-color-container",
        activeColor: "brand-color",
        textAntiColor: "text-color-anti",
        textSize:16,
        panelSize:200
      };
    }
    if (ports) {
      this.ports = ports;
    } else {
      this.ports = this.assembleDefaultPorts();
    }
  }

  assembleDefaultPorts() {
    const superState = super.assembleDefaultPorts();
    return {
      ...superState,
      values: [
        ...superState.values,
        {
          name: "当前操作的预设",
          key: "presetNum",
          type: "string",
          value: "1",
        },
        {
          name: "PTZ速度",
          key: "ptzSpeed",
          type: "int",
          value: 100,
        },
      ],
      events: [
        {
          name: "长按事件",
          key: `longPress-${this.id}`,
          eventType: "longPress",
          type: "event",
          value: {
            time: 1 //长按触发时间(秒)
          },
          action: [],
        },
        {
          name: "预设保存",
          key: "savePreset",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "预设调用",
          key: "callPreset",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "电源调节开",
          key: "setPowerOn",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "电源调节关",
          key: "setPowerOff",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "向左转动",
          key: "panLeft",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "向右转动",
          key: "panRight",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "左右转动停止",
          key: "panStop",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "向上转动",
          key: "tiltUp",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "向下转动",
          key: "tiltDown",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "上下转动停止",
          key: "tiltStop",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "缩放放大",
          key: "zoomIn",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "缩放缩小",
          key: "zoomOut",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "缩放停止",
          key: "zoomStop",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "聚焦靠近",
          key: "focusNear",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "聚焦远离",
          key: "focusFar",
          eventType: "custom",
          type: "event",
          action: [],
        },
        {
          name: "聚焦停止",
          key: "focusStop",
          eventType: "custom",
          type: "event",
          action: [],
        }
      ],
    };
  }
}
